﻿Imports System.ComponentModel
Imports SecretaryToolData

Public Class frmAttendance

	Private ReadOnly Property TypedReportLocationsBindingSource As BindingList(Of String)
		Get
			Return CType(ReportLocationsBindingSource.DataSource, BindingList(Of String))
		End Get
	End Property

	Private ReadOnly Property TypedReportMonthBindingSource As BindingList(Of DateTime)
		Get
			Return CType(ReportMonthBindingSource.DataSource, BindingList(Of DateTime))
		End Get
	End Property

	Private ReadOnly Property TypedAttendanceBindingSource As Attendance
		Get
			Return CType(AttendanceBindingSource.DataSource, Attendance)
		End Get
	End Property

	Private Sub btnClose_Click(sender As System.Object, e As System.EventArgs) Handles btnClose.Click
		Me.Close()
	End Sub

	Private Sub SetBindings()
		ReportMonthBindingSource.DataSource = Attendance.Months
		ReportLocationsBindingSource.DataSource = Attendance.CountIdentifiers
		ReportMonthBindingSource.ResetBindings(False)
		ReportLocationsBindingSource.ResetBindings(False)

	End Sub

	Private Sub RefreshAttendance()
		'AttendanceBindingSource.DataSource = New Attendance(cmboMonth.SelectedItem, cmboLocation.SelectedText)
		AttendanceBindingSource.DataSource = New Attendance(cmboMonth.SelectedItem)
		AttendanceBindingSource.ResetBindings(False)
	End Sub

	Private Sub frmAttendance_Load(sender As Object, e As System.EventArgs) Handles Me.Load
		SetBindings()
		cmboMonth.SelectedItem = Now.FirstOfTheMonth
		RefreshAttendance()
	End Sub

	Private Sub cmboMonth_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles cmboMonth.SelectedIndexChanged
		RefreshAttendance()
	End Sub
End Class